import type { Product } from '@/types/product'
import { defineStore } from 'pinia'
// import type { PersistenceOptions } from 'pinia-plugin-persistedstate'
import { ref } from 'vue'

// 定义首页展示数据的 store
export const useProductStore = defineStore(
  'product',
  () => {
    // 存储商品列表
    const productList = ref<Product[]>([])
    // 当前页码
    const currentPage = ref<number>(1)
    // 每页显示的商品数量
    const pageSize = ref<number>(20)
    // 是否还有更多商品
    const hasMore = ref(true)
    return { productList, currentPage, pageSize, hasMore }
  },
  //不开启持久化
  // {
  //   persist: {
  //     key: 'productStore',
  //     paths: ['product', 'currentPage', 'pageSize', 'hasMore'],
  //     storage: window.localStorage,
  //   } as PersistenceOptions,
  // },
)
